#pragma once


#define PROPERTY_GET(name, Type, getter)\
	public:\
	void Set##name(Type val)\
	{\
		m_##name = val;\
		}\
	private:\
	__declspec ( property ( put = Set##name, get = getter ) ) Type name;\
	Type m_##name;

#define PROPERTY_SET(name, Type, setter)\
	public:\
	Type& Get##name(void) const\
	{\
	return m_##name;\
	}\
	private:\
	__declspec ( property ( put = setter, get = Get##name ) ) Type name;\
	Type m_##name;

#define PROPERTY(name, Type)\
	public:\
	Type Get##name(void) const\
	{\
	return m_##name;\
	}\
	PROPERTY_GET(name, Type, Get##name);

#ifdef WIN32
#define PRINT(STR, LEVEL) DisplayMsg(STR, LEVEL)
#elif defined(linux) 
#define PRINT(STR, LEVEL) cout<<STR<<endl
#endif

#define APPENDMSG(action, msg, level) \
	if(level>=0){\
	stringstream ss;\
	if (level<10){\
		ss<<"["<<Util::GetCTime()<<"]";\
	}\
	ss<<action->Signature()<<" ";\
	ss<<msg;\
	PRINT(ss.str(), level);\
	if (_filelog && (level==2||level==3||level==0))\
	{\
		_filelog->AppendInfo(ss.str());\
	}\
	}else (void)(0)

#define APPENDMSGEX(msg, level) \
	if(level>=0){\
	stringstream ss;\
	if (level<10){\
		ss<<"["<<Util::GetCTime()<<"] ";\
	}\
	ss<<msg;\
	PRINT(ss.str(), level);\
	if (_filelog)\
	{\
		switch (level)\
		{\
		case 3:\
			_filelog->AppendInfo(ss.str());\
			break;\
		case 2:\
			_filelog->AppendWarning(ss.str());\
			break;\
		case 1:\
			/* doing nothing.*/\
			break;\
		case 0:\
			_filelog->AppendDebug(ss.str());\
			break;\
		}\
	}\
	}else (void)(0)


#ifdef _DEBUG
#define APPENDMSGEXD(msg, level) APPENDMSGEX(msg, level)
#else
#define APPENDMSGEXD(msg, level) (void) (0)
#endif

#define STR_VALUE(name) #name
#define PROPERTY_TASKINFO_GET(name, getter)\
	public:\
	void Set##name(const std::string& val)\
	{ clientInfos[STR_VALUE(name)] = val;}\
	private:\
	__declspec(property(put = Set##name, get = getter)) std::string name;

#define PROPERTY_TASKINFO(name)\
	public:\
	std::string Get##name(void) const\
	{ return clientInfos[STR_VALUE(name)];}\
	PROPERTY_TASKINFO_GET(name, Get##name)

